package com.ayuku.retail.business.function;

import java.util.GregorianCalendar;
import java.util.List;

import com.ayuku.commons.AyukuDB;
import com.ayuku.retail.persistence.model.AppFunctions;
import com.ayuku.retail.persistence.model.AppUserGroupFunc;

public class FunctionImpl {
	public static void main(String args[]) throws Exception {
		AyukuDB.openDB();
		
		List<AppFunctions> lst = AyukuDB.getPersist().readList(
				AppFunctions.class,
				"SELECT * FROM app_functions WHERE id is not null");

		AyukuDB.getPersist().executeUpdate(
				"delete from app_user_group_func where group_id = 'administrator'");

		for (int i = 0; i < lst.size(); i++) {
			AppFunctions str = lst.get(i);
			AppUserGroupFunc func = new AppUserGroupFunc();
			func.setGroupId("administrator");
			func.setFuncId(str.getId()); 
			func.setAccessAdd("true");
			func.setAccessDelete("true");
			func.setAccessEdit("true");
			func.setAccessView("true");
			func.setCreatedDate(new GregorianCalendar().getTime());
			func.setModifiedDate(new GregorianCalendar().getTime());
			func.setCreatedBy("administrator");
			func.setModifiedBy("administrator");
			AyukuDB.getPersist().insert(func);
		}
		
		AyukuDB.getPersist().executeUpdate(
		"commit");

	}
};
